package com.dzf.controller;


import com.dzf.entity.BookType;
import com.dzf.entity.RespJson;
import com.dzf.service.BookTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/api/adm/type")
public class AdmBookTypeController {
    @Autowired
    BookTypeService bookTypeService;


    @RequestMapping("/findAll")
    public RespJson findAll(){
        return RespJson.pack(200,"OK",bookTypeService.findAll());
    }


    @RequestMapping("/findById/{id}")
    public RespJson findById(@PathVariable("id") int id){

        return RespJson.pack(200,"",bookTypeService.findById(id));
    }

    @PostMapping("/add")
    public RespJson amend(@RequestBody BookType bookType)
    {
        bookTypeService.amend(bookType);
        return RespJson.pack(200,"添加成功",bookTypeService.findAll());
    }


}
